import java.util.ArrayList;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;

/**
 * Class for ReswellTable Object
 * Note: a ReswellTable contains ReswellFields.
 * @author jcoston
 */
public class ReswellTable {
	
	private ArrayList<ReswellField> fields = new ArrayList<ReswellField>();
	private String tname;

	/**
	 * Constructor
	 * @param key
	 * @param tname The name of the table
	 * @param fields2 The list of the fields
	 */
	public ReswellTable(String tname, JsonArray fields2) {
		this.tname = tname;
		for (JsonElement elem : fields2) {
        	String alternate = elem.getAsJsonObject().get("alternate").getAsString();
        	String fieldname = elem.getAsJsonObject().get("fieldname").getAsString();
        	this.fields.add(new ReswellField(alternate, fieldname));
        }
	}

	/**
	 * Get the list of fields
	 * @return the list of fields
	 */
	public ArrayList<ReswellField> getFields() {
		//Add table to front of fields
		return fields;
	}

	public String getTname() {
		return tname;
	}

	
}
